﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_BGM_ProjectReport : IBLL_BGM_ProjectReport
    {
        Common common = new Common();
        private static readonly IDAL_BGM_ProjectReport dal = DataAccess.Create_BGM_ProjectReport();

        public B_BGM_ProjectReport()
        {

        }

        public IList<M_BGM_ProjectReport> GetFull(string bgm_proj_seq
            , string bgm_proj_exp_seq, string rpt_type)
        {
            Nullable<int> nbgm_proj_seq = common.ConvertNullInt(bgm_proj_seq);
            Nullable<int> nbgm_proj_exp_seq = common.ConvertNullInt(bgm_proj_exp_seq);
            Nullable<int> nrpt_type = common.ConvertNullInt(rpt_type);
            return dal.GetFull(nbgm_proj_seq, nbgm_proj_exp_seq, nrpt_type);
        }

        public IList<M_BGM_ProjectReport> GetList(string bgm_proj_seq
            , string bgm_proj_exp_seq, string rpt_type)
        {
            Nullable<int> nbgm_proj_seq = common.ConvertNullInt(bgm_proj_seq);
            Nullable<int> nbgm_proj_exp_seq = common.ConvertNullInt(bgm_proj_exp_seq);
            Nullable<int> nrpt_type = common.ConvertNullInt(rpt_type);
            return dal.GetList(nbgm_proj_seq, nbgm_proj_exp_seq, nrpt_type);
        }

        public IList<M_BGM_ProjectReport> GetCalculateList(string bgm_proj_seq
            , string bgm_proj_exp_seq, string rpt_type, string bgm_rec_exp_seq
            , string bgm_trans_from_seq, string bgm_trans_to_seq
            , string icm_ppr_item_seq, string icm_pr_item_seq
            , string icm_po_item_seq, string icm_dn_item_seq
            , string bgm_proj_oper_exp_seq)
        {
            Nullable<int> nbgm_proj_seq = common.ConvertNullInt(bgm_proj_seq);
            Nullable<int> nbgm_proj_exp_seq = common.ConvertNullInt(bgm_proj_exp_seq);
            Nullable<int> nrpt_type = common.ConvertNullInt(rpt_type);
            Nullable<int> nbgm_rec_exp_seq = common.ConvertNullInt(bgm_rec_exp_seq);
            Nullable<int> nbgm_trans_from_seq = common.ConvertNullInt(bgm_trans_from_seq);
            Nullable<int> nbgm_trans_to_seq = common.ConvertNullInt(bgm_trans_to_seq);
            Nullable<int> nicm_ppr_item_seq = common.ConvertNullInt(icm_ppr_item_seq);
            Nullable<int> nicm_pr_item_seq = common.ConvertNullInt(icm_pr_item_seq);
            Nullable<int> nicm_po_item_seq = common.ConvertNullInt(icm_po_item_seq);
            Nullable<int> nicm_dn_item_seq = common.ConvertNullInt(icm_dn_item_seq);
            Nullable<int> nbgm_proj_oper_exp_seq = common.ConvertNullInt(bgm_proj_oper_exp_seq);
            return dal.GetCalculateList(nbgm_proj_seq, nbgm_proj_exp_seq, nrpt_type
                , nbgm_rec_exp_seq, nbgm_trans_from_seq, nbgm_trans_to_seq, nicm_ppr_item_seq
                , nicm_pr_item_seq, nicm_po_item_seq, nicm_dn_item_seq, nbgm_proj_oper_exp_seq);
        }

        public M_BGM_ProjectReport GetInfo(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public void Insert(M_BGM_ProjectReport info)
        {
            try
            {
                dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_BGM_ProjectReport info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_BGM_ProjectReport info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }

        public void UpdateStatus(M_BGM_ProjectReport info)
        {
            try
            {
                dal.UpdateStatus(info);
            }
            catch
            {
                throw;
            }
        }
    }
}
